<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<%@include file="index.jsp"%>
<h1 align="center">批量修改</h1>


<form action="${pageContext.request.contextPath}/updateBatch" method="post">
    <table border="1" cellspacing="0" cellpadding="15" align="center">
        <tr>
            <th>序号</th>
            <th>用户名</th>
            <th>性别</th>
            <th>生日</th>
            <th>手机号</th>
            <th>邮箱</th>
            <th>爱好</th>
            <th>类型</th>
        </tr>
        <c:forEach items="${requestScope.list}" var="user" varStatus="stat">

        <tr>

            <td>
                    ${stat.index+1}
                <input type="hidden" name="list[${stat.index}].id"  value="${user.id}"/>
            </td>
            <td>
                <input type="text" name="list[${stat.index}].username" value="${user.username}" />
            </td>
            <td>
                <input type="radio" name="list[${stat.index}].gender"  value="nan" ${user.gender == 'nan'?'checked':''} />男
                <input type="radio" name="list[${stat.index}].gender"  value="nv" ${user.gender == 'nv'?'checked':''} />女
            </td>
            <td>
                <input type="date" name="list[${stat.index}].birthday" value="${user.birthday}" />
            </td>
            <td>

                <input type="text" name="list[${stat.index}].phonenum" id="phonenum" value="${user.phonenum}" size="30" />
            </td>
            <td>

                        <input type="text" name="list[${stat.index}].email" id="email" value="${user.email}" size="30" />
            </td>
            <td>
                        <input type="checkbox" name="list[${stat.index}].hobby" size="30" value="basketball"
                            ${fn:contains(user.hobby,'basketball')?'checked':''}
                        />篮球
                        <input type="checkbox" name="list[${stat.index}].hobby" size="30" value="football"
                            ${fn:contains(user.hobby,'football')?'checked':''}
                        />足球
                        <input type="checkbox" name="list[${stat.index}].hobby" size="30" value="dance"
                            ${fn:contains(user.hobby,'dance')?'checked':''}
                        />跳舞
                        <input type="checkbox" name="list[${stat.index}].hobby" size="30" value="music"
                            ${fn:contains(user.hobby,'music')?'checked':''}
                        />音乐
            </td>
            <td>

                        <select name="list[${stat.index}].type" id="type">
                            <option value="">请选择</option>
                            <option value="黑铁客户"${user.type == '黑铁客户'?'selected':''}>黑铁客户</option>
                            <option value="青铜客户"${user.type == '青铜客户'?'selected':''}>青铜客户</option>
                            <option value="黄金客户" ${user.type == '黄金客户'?'selected':''}>黄金客户</option>
                            <option value="钻石客户" ${user.type == '钻石客户'?'selected':''}>钻石客户</option>
                        </select>
            </td>
        </tr>
        </c:forEach>
    </table>
    <p style="text-align: center"><input type="button" value="批量修改" onclick="xiugai()" /></p>
</form>
</body>
</html>
<script src="${pageContext.request.contextPath}/js/jquery-1.12.4.min.js"></script>
<script>

    function xiugai(){
        var isxiu = confirm("您确认修改吗?");
        if(isxiu){
            document.forms[0].submit();
        }else {
            location.href="${pageContext.request.contextPath}/updateBatch/list";
        }
    }

</script>
<script>
        $("th input").click(function(){
        $(".tt input").prop("checked",$(this).prop("checked"));
    })
        $(".tt input").click(function(){
        $("th input").prop("checked",$(".tt input").length == $(".tt input:checked").length)
    })
</script>
